package cn.xiaojingyu.framework.controller;

import cn.xiaojingyu.framework.pojo.entity.Test;
import cn.xiaojingyu.framework.repository.TestRepository;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author dan
 * @date 2024/7/5 16:43
 */
@Slf4j
@RestController
@RequestMapping("/framework")
@Tag(name = "测试模块")
public class TestController {


    @RequestMapping("message")
    @Operation(summary = "获取通信成功信息")
    public String message() {
        return "项目启动成功, 访问测试接口成功!";
    }

    @Autowired
    TestRepository testRepository;

    @RequestMapping("testJpa")
    @Operation(summary = "测试Jpa是否正常使用")
    public String testJpa() {
        Test test = new Test();
        test.setName("test");
        Test save = testRepository.save(test);
        return "jpa测试成功, 新增一条记录, id:" + save.getId();
    }

}
